<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function doBack(){
            window.history.back();//后退
        }
        function doForward(){
            window.history.forward();//前进
        }
        function doBack2(){
            // history.go(number)指定前进或者后退
            window.history.go(-2);
        }
        function doForward2(){
            window.history.go(1);
        }
        function doGo(){
            history.go(0);
        }
        function getLoc(){
            console.log(window.location.href);//获取当前地址
        }
        function setLoc(){
            window.location.href="https://www.baidu.com";//设置跳转地址
        }
        function doReload(){
            location.reload();//重新加载，刷新
        }
    </script>
</head>
<body>
    <input type="button" value="后退" onclick="doBack()">
    <input type="button" value="前进" onclick="doForward()">
    <input type="button" value="后退2页" onclick="doBack2()">
    <input type="button" value="前进1页" onclick="doForward2()">
    <input type="button" value="刷新" onclick="doGo()">
    <input type="button" value="获取地址" onclick="getLoc()">
    <input type="button" value="设置地址，跳转地址" onclick="setLoc()">
    <input type="button" value="刷新" onclick="doReload()">
</body>
</html>